<div id = "menu" name = "menu" class = "menu">

    <p id= "user" name = "user" class ="user">Inloggad som: <?php echo $_SESSION['username']; ?> <p/>
    <P>Mina kurser:</P> 

    <!--php script used to output the courses a student participate in-->
    <?php
    $uname = $_SESSION['username'];

    /* -------------------------------------------------------- */
    // mysql database connection
    $user = $_SESSION['user'];
    $password = $_SESSION['password'];
    $database = $_SESSION['database'];
    $host = $_SESSION['host'];

    $con = mysqli_connect($host, $user, $password, $database);
    /* -------------------------------------------------------- */


    //verifies  that connection is succesfull if not display error message
    if (mysqli_connect_errno()) {
        echo "sorry! couldn't connect to database " . mysqli_connect_error();
    }

    /* --------------------------------------------------------------------------------------- */
    // fills side panel with values
    //create a myslq query that selects courses associated with a specifik username
    $result = mysqli_query($con, "select COURSE.COURSE_ID, COURSE_NAME from PERSON_TAKES_COURSE, 
                                COURSE, USER_INFO  WHERE USERNAME='$uname' AND  PERSON_TAKES_COURSE.ID = USER_INFO.ID 
                                AND PERSON_TAKES_COURSE.COURSE_ID = COURSE.COURSE_ID;");


    while ($row = mysqli_fetch_array($result)) {
        echo "<p>" . "<span id = \"date\">" . $row['COURSE_ID'] . "</span>" . " " . "<span id = \"sign\">" . $row['COURSE_NAME'] . "</p>";

        echo "<form name = \"frm1\" id =\"frm1\" action=\"quizzar.php\" method=\"post\" target =\"content\">";
        echo "<input class=\"hide\" type=\"text\" name=\"coursename\" id = \"coursename\" value=" . $row['COURSE_NAME'] . ">";
        echo "<input class=\"hide\" type=\"text\" name=\"courseid\" id = \"courseid\" value=" . $row['COURSE_ID'] . ">";

        echo "<input type=\"submit\" value=\"Quizzar\" class=\"butext\">";
        echo"</form>";

        echo "<form name = \"frm1\" id =\"frm1\" action=\"flashcards.php\" method=\"post\" target =\"content\">";
        echo "<input class=\"hide\" type=\"text\" name=\"courseid\" id = \"courseid\" value=" . $row['COURSE_ID'] . ">";
        echo "<input class=\"hide\" type=\"text\" name=\"coursename\" id = \"coursename\" value=" . $row['COURSE_NAME'] . ">";
        echo "<input type=\"submit\" value=\"Flashcards\" class=\"butext\">";
        echo"</form>";
    }
    mysqli_close($con); // close connection
    ?>

</div>

